package com.example.demo.gouzaoqi;

public class java8 {
    public static void main(String[] args) {
        java8 tester = new java8();
        MathOperation addOperation = (int a,int b)->a+b;

        MathOperation subStraction = ( a, b)->a-b;

        MathOperation multOperation = (int  a,int b)->{return a-b;};

        MathOperation division = (int  a,int b) ->a/b;
        System.out.println("10 + 5 = " + tester.operate(10, 5, addOperation));
        System.out.println("10 - 5 = " + tester.operate(10, 5, subStraction));
        System.out.println("10 x 5 = " + tester.operate(10, 5, multOperation));
        System.out.println("10 / 5 = " + tester.operate(10, 5, division));


         getService gs = (message)-> System.out.println("hello"+message);
        getService gs2 = message-> System.out.println("hello"+message);
        gs.sayMessage("gs");
        gs2.sayMessage("gs2");
    }

    interface MathOperation{
        int operation(int a,int b);
    }

    interface getService{
        void sayMessage(String sayMessage);
    }

    private int operate(int a,int b,MathOperation mathOperation){
        return mathOperation.operation(a,b);
    }
}

